import request from './request'

// 用户登录
export const login = (data) => {
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

// 退出登录
export const logout = () => {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

// 获取当前用户信息
export const getCurrentUser = () => {
  return request({
    url: '/user/current',
    method: 'get'
  })
}

// 获取用户列表
export const getUserList = () => {
  return request({
    url: '/user/list',
    method: 'get'
  })
}

// 创建用户
export const createUser = (data) => {
  return request({
    url: '/user/create',
    method: 'post',
    data
  })
}

// 更新用户状态
export const updateUserStatus = (userId, status) => {
  return request({
    url: `/user/status/${userId}/${status}`,
    method: 'put'
  })
}

// 重置密码
export const resetPassword = (userId, newPassword) => {
  return request({
    url: '/user/reset-password',
    method: 'put',
    params: { userId, newPassword }
  })
}

// 修改密码
export const changePassword = (data) => {
  return request({
    url: '/user/change-password',
    method: 'put',
    data
  })
}

